<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/tabs.jsp"%>
<%@ include file="/commons/dateTime.jsp" %>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/validation/validation.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>

<script type="text/javascript">
	var ACTION_URL="${ctx}/charge_calculateAction.do?";

	function setHouseInfo(houseInfo)
	{
		var houseIds="";
		var houseNumbers="";
		for(var i=0;i<houseInfo.length;i++){
			houseIds += houseInfo[i].houseId+",";
			houseNumbers += houseInfo[i].houseNumber+",";
		}
		$('houseIds').value=getStr(houseIds);
		$('houseNumbers').value=getStr(houseNumbers);
	}

	//返回去掉最后一个,号的字符串
	function getStr(str){
		if(str.lastIndexOf(",")>=0){
			return str.substr(0,str.length-1);
		}else{
			return str;
		}
	}

	function openChoiceHouse()
	{
		var url = "${ctx}/common_commonAction.do?method=chooseMultiHouseWithBuild";
		top.windowOpen(url, "openHouseChoose", "${key.houseSelect}", 580, 800);
	}

	function chargeValue(obj){
		$('charType').value=obj.options[obj.selectedIndex].code;
	}

	//重算
	function reCalculate(){
			var url=ACTION_URL+"method=recalculation";
			var pars=$('form1').serialize();
			var isTure=$("form1").fireEvent("onSubmit");
			if(isTure){
				closeORopenButton();
				sendAjaxRequest(url,pars,function (result) {
					ajaxSubmitException(result.responseText);
					if(result.responseText=="ok"){
						showResponseRe();
						SuccessAlert("${key.success}");
					}else{
						var obj = findFrame('cashieringList');
						if(obj == undefined || obj == null){
						  obj=findFrame('main');
						}else{
						  obj=findFrame('connTabPanel');
						}
						
						obj.downExcelFileName = result.responseText;
						//alert(downExcelFileName);//有房间未重算，是否需要详细信息?
						AskConfirm("有房间未重算，是否需要详细信息?","main","getRecalculation");
						//FailureAlert("${key.fail}");
					}
					closeORopenButton();
					//showResponseRe();
					windowClose();
				});
			}
	}

	//关闭或打开按钮事件
	function closeORopenButton(){
		$$('window_footer').disabled= !$$('window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
	}

	//重算操作的响应
	function showResponseRe(){
		var obj = findFrame('cashieringList');
		if(obj == undefined || obj == null){
		  obj=findFrame('main');
		}else{
		  obj=findFrame('connTabPanel');
		}
		obj.search();
	}

	function init(){
		var houseId='${houseId}';
		if(houseId!=""){
			$('shouseNumbers').show();
			$('houseNumbers').hide();
			$('img1').hide();
			$('thouseNumber').className="aux_intable_td2";
		}

	}
</script>
<body onload="init();">
<form action="" method="post" class="required-validate" name="form1">
<input type="hidden" name="periodId" value="${period.keyword}">
<input type="hidden" name="houseIds" value="${houseId}">
<input type="hidden" id="endDate" value="${period.endDate}">
<input type="hidden" name="charType">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="121"><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"><span class="window_head_intext">重算</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">

          <tr>
            <td class="aux_intable_td1">${key.currentPeriod}：</td>
            <td class="aux_intable_td2">${period.period}</td>
            </tr>

    <tr>
	            <td class="aux_intable_td1">当前管理区：</td>

	            <td class="aux_intable_td1">${period.precinctName}</td>
            </tr>
            <tr>
              <td class="aux_intable_td1">截止缴费日期：</td>
              <td class="aux_intable_td2">
              <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>${period.firstPayDate}</td>
                </tr>
              </table>
              </td>
            </tr>

           <tr>
              <td class="aux_intable_td1">优惠期截止缴费日期：</td>
              <td class="aux_intable_td2">
              <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>${period.lastPayDate}</td>
                </tr>
              </table>
              </td>
            </tr>

          <tr>
            <td class="aux_intable_td1"><span id="roomnum">${key.houseScopeSelect}：</span></td>
            <td class="aux_intable_require" id="thouseNumber"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td ><input name="houseNumbers" type="text" class="inputtext required" value=" " readonly="readonly" size="16"><span id="shouseNumbers" style="display: none;">${houseNumber}</span></td>
                <td width="4">&nbsp;</td>
                <td ><div id="img1"><a href="#"  onClick="openChoiceHouse()" onFocus="this.blur()"><img src="${ctx}/images/ico_houesno.GIF" alt="${key.selectTip}" border="0"></a></div></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td class="aux_intable_td1">${key.chargeType}：</td>
            <td class="aux_intable_require">
            <mypms:Sysrefcode name="ss" code="FEE_CHAR_TYPE_CLASS_CODE" filterStr="'001','002','003'" className="width:110px; required" onchange="chargeValue(this)">
            </mypms:Sysrefcode>
          </tr>


        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
        <td class="btn_between_space">&nbsp;</td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="reCalculate();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.ok}</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.close}</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>

<script type="text/javascript">

</script>
</body>
</html>